USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[MimeTypes-Insert]    Script Date: [[20120914064957]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064957]]
-- Description:	Insert record into table [dbo].[MimeTypes]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[MimeTypes-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[MimeTypes-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[MimeTypes-Insert]
	/*@Mime_RowNumber int =Null OUTPUT , 
	@Mime_ID uniqueidentifier =Null  , 
	@Mime_NameAr varchar(300) =Null  , 
	@Mime_NameEn varchar(300) =Null  , 
	@Mime_Notes varchar(max) =Null  , 
	@Mime_Search varchar(max) =Null  , 
	@MimeType_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[MimeTypes](/*[Mime_ID], [Mime_NameAr], [Mime_NameEn], [Mime_Notes], [Mime_Search]*/)
	VALUES     (/*@Mime_ID, @Mime_NameAr, @Mime_NameEn, @Mime_Notes, @Mime_Search*/)

	/*SELECT @Mime_RowNumber = [Mime_RowNumber], @MimeType_TimeStamp = [MimeType_TimeStamp]
    FROM [dbo].[MimeTypes]
    WHERE  ( [Mime_ID] =@Mime_ID )
	AND  ( [Mime_NameAr] =@Mime_NameAr )
	AND  ( [Mime_NameEn] =@Mime_NameEn )
	AND  ( [Mime_Notes] =@Mime_Notes )
	AND  ( [Mime_Search] =@Mime_Search )*/
END
GO
-- =============================================
USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[MimeTypes-update]    Script Date: [[20120914064957]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064957]]
-- Description:	Update record in table [dbo].[MimeTypes]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[MimeTypes-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[MimeTypes-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[MimeTypes-update]
	/*@Mime_RowNumber int =Null OUTPUT , 
	@Mime_ID uniqueidentifier =Null  , 
	@Mime_NameAr varchar(300) =Null  , 
	@Mime_NameEn varchar(300) =Null  , 
	@Mime_Notes varchar(max) =Null  , 
	@Mime_Search varchar(max) =Null  , 
	@MimeType_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [MimeType_TimeStamp]
    FROM [dbo].[MimeTypes]
    	WHERE ([Mime_ID] = @Mime_ID)

    IF  @OldTimeStamp = @MimeType_TimeStamp
    BEGIN*/
		Update [dbo].[MimeTypes] SET 
		/*[Mime_ID] =@Mime_ID, 
		[Mime_NameAr] =@Mime_NameAr, 
		[Mime_NameEn] =@Mime_NameEn, 
		[Mime_Notes] =@Mime_Notes, 
		[Mime_Search] =@Mime_Search*/
		/*WHERE ([Mime_ID] = @Mime_ID)*/
	/*END*/

	/*SELECT @Mime_RowNumber = [Mime_RowNumber], @MimeType_TimeStamp = [MimeType_TimeStamp]
    FROM [dbo].[MimeTypes]
	WHERE ([Mime_ID] = @Mime_ID)*/
END
GO
-- =============================================
USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[MimeTypes-Insert-Update]    Script Date: [[20120914064958]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064958]]
-- Description:	Insert OR Update record into table [dbo].[MimeTypes]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[MimeTypes-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[MimeTypes-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[MimeTypes-Insert-Update]
	/*@Mime_RowNumber int =Null OUTPUT , 
	@Mime_ID uniqueidentifier =Null  , 
	@Mime_NameAr varchar(300) =Null  , 
	@Mime_NameEn varchar(300) =Null  , 
	@Mime_Notes varchar(max) =Null  , 
	@Mime_Search varchar(max) =Null  , 
	@MimeType_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[MimeTypes] 
					/*WHERE ([Mime_ID] = @Mime_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[MimeTypes](/*[Mime_ID], [Mime_NameAr], [Mime_NameEn], [Mime_Notes], [Mime_Search]*/)
		VALUES     (/*@Mime_ID, @Mime_NameAr, @Mime_NameEn, @Mime_Notes, @Mime_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [MimeType_TimeStamp]
		FROM [dbo].[MimeTypes]
    	WHERE ([Mime_ID] = @Mime_ID)

		IF  @OldTimeStamp = @MimeType_TimeStamp
		BEGIN*/
			Update [dbo].[MimeTypes] SET 
			/*[Mime_ID] =@Mime_ID, 
			[Mime_NameAr] =@Mime_NameAr, 
			[Mime_NameEn] =@Mime_NameEn, 
			[Mime_Notes] =@Mime_Notes, 
			[Mime_Search] =@Mime_Search*/
			/*WHERE ([Mime_ID] = @Mime_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @Mime_RowNumber = [Mime_RowNumber], @MimeType_TimeStamp = [MimeType_TimeStamp]
    FROM [dbo].[MimeTypes]
	WHERE ([Mime_ID] = @Mime_ID)*/
END
GO
-- =============================================
USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[MimeTypes-Delete]    Script Date: [[20120914064958]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064958]]
-- Description:	delete records from table [dbo].[MimeTypes] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[MimeTypes-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[MimeTypes-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[MimeTypes-Delete]
	/*@Mime_RowNumber int =null  , 
	@Mime_ID uniqueidentifier =null  , 
	@Mime_NameAr varchar(300) =null  , 
	@Mime_NameEn varchar(300) =null  , 
	@Mime_Notes varchar(max) =null  , 
	@Mime_Search varchar(max) =null  , 
	@MimeType_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[MimeTypes]
	WHERE /*( [Mime_RowNumber] = ISNULL(@Mime_RowNumber, [Mime_RowNumber]) )
	AND ( [Mime_ID] = ISNULL(@Mime_ID, [Mime_ID]) )
	AND ( [Mime_NameAr] like ISNULL(@Mime_NameAr, [Mime_NameAr]) )
	AND ( [Mime_NameEn] like ISNULL(@Mime_NameEn, [Mime_NameEn]) )
	AND ( [Mime_Notes] like ISNULL(@Mime_Notes, [Mime_Notes]) )
	AND ( [Mime_Search] like ISNULL(@Mime_Search, [Mime_Search]) )
	AND ( [MimeType_TimeStamp] = ISNULL(@MimeType_TimeStamp, [MimeType_TimeStamp]) )*/
END
GO
-- =============================================
USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[MimeTypes-Select]    Script Date: [[20120914064958]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064958]]
-- Description:	select records from table [dbo].[MimeTypes] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[MimeTypes-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[MimeTypes-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[MimeTypes-Select]
	/*@Mime_RowNumber int =null  , 
	@Mime_ID uniqueidentifier =null  , 
	@Mime_NameAr varchar(300) =null  , 
	@Mime_NameEn varchar(300) =null  , 
	@Mime_Notes varchar(max) =null  , 
	@Mime_Search varchar(max) =null  , 
	@MimeType_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[MimeTypes]
	WHERE /*( [Mime_RowNumber] = ISNULL(@Mime_RowNumber, [Mime_RowNumber]) )
	AND ( [Mime_ID] = ISNULL(@Mime_ID, [Mime_ID]) )
	AND ( [Mime_NameAr] like ISNULL(@Mime_NameAr, [Mime_NameAr]) )
	AND ( [Mime_NameEn] like ISNULL(@Mime_NameEn, [Mime_NameEn]) )
	AND ( [Mime_Notes] like ISNULL(@Mime_Notes, [Mime_Notes]) )
	AND ( [Mime_Search] like ISNULL(@Mime_Search, [Mime_Search]) )
	AND ( [MimeType_TimeStamp] = ISNULL(@MimeType_TimeStamp, [MimeType_TimeStamp]) )*/
END
GO
-- =============================================
